- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8
Add Timestamp() to extract attestation timestamp #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Timestamp() to extract attestation timestamp
      Timestamp() to extract attestation timestamp| // (p. 64) describes Timestamp as "UTC time when document was created, | ||
| // in milliseconds" | ||
| msec := int64(doc.Timestamp) | ||
| return time.Unix(msec/1e3, (msec%1e3)*1e6), nil | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In go1.17 this line could be
return time.UnixMilli(int64(d.Timestamp)), nilbut I didn't want to bump the golang dependency.
| timeToMillis := func(t time.Time) uint64 { | ||
| return uint64(t.UnixNano() / 1e6) | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In go1.17 we could use time.UnixMilli, but I didn't want to bump the go version
| Yeah sure I'll have some time this weekend and check out this proposal! | 
Overview
This PR adds the
Timestampfunction to extract the attestation timestamp, which can be used to setVerifyOptions.CurrentTimetoVerifyif an attestation was valid when it was created.Why we propose the change
Our application archives AWS Nitro Enclave attestations. We want to be able to verify these attestations at a future time. However, verifying an attestation at a future can fail in
nitrite.Verifyatdue to certificate expiration if
currentTimeexceeds anintermediatescertificateNot Aftervalue.The
nitritelibrary provides thenitrite.VerifyOptions.CurrentTimeto set thecurrentTimeused in certificate validation. We would like to set that time to attestationDocument.Timestamp, butnitritedoes not currently export thecosePayloadto parse our theTimestampon the client.We propose to extend
nitritewithfunc Timestamp(data []byte) (time.Time, error)to extract the attestation timestamp on the client.Why is the proposed change useful in the
nitridinglibraryFor the client to extract attestation
Document.Timestamp, the client needs tocbor.Unmarshalanitrite.cosePayload, which is not exported bynitrite. While the client could redefine acosePayloadin its context, that is not very DRY and the client's definition ofcosePayloadcould drift from the library. Alternatively,nitritecould export theCOSEPayload, but that is a more significant change to thenitritelibrary than our proposal. Either of these approaches put a burden on the client for extracting attestation information to feed it back tonitrite, while replicating attestation parsing functionality that is already implemented bynitrite.Adding the Timestamp function augments the existing
nitriteinterface and allows it to support the attestation archival use case with the existing options pattern.